package org.jeecg.modules.columnImg.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecgframework.poi.excel.annotation.Excel;

import java.io.Serializable;
import java.io.UnsupportedEncodingException;

/**
 * @Description: 栏目图片
 * @Author: jeecg-boot
 * @Date:   2020-12-13
 * @Version: V1.0
 */
@Data
@TableName("phil_column_img")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="phil_column_img对象", description="栏目图片")
public class PhilColumnImg implements Serializable {
    private static final long serialVersionUID = 1L;

	/**主键*/
	@TableId(type = IdType.ASSIGN_ID)
    @ApiModelProperty(value = "主键")
    private java.lang.String id;
	/**图片*/
	@Excel(name = "图片", width = 15)
    private transient java.lang.String imgString;

    private byte[] img;

    public byte[] getImg(){
        if(imgString==null){
            return null;
        }
        try {
            return imgString.getBytes("UTF-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return null;
    }

    public String getImgString(){
        if(img==null || img.length==0){
            return "";
        }
        try {
            return new String(img,"UTF-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return "";
    }
}
